<template>
  <div class="login-box" style="background:url('/images/backgroud.png') no-repeat;background-size: cover">

    <el-form ref="form" :model="form" label-width="80px" class="login-form">
        <div class="title logo-box" style="border-bottom: 1px solid rgb(187, 187, 187);margin-right: 10px;">
          <div class="logo fl" style="background:url('/images/logo.png') no-repeat;background-size: 100% 100%;"></div>
          系统名称
        </div>
        <el-form-item label="账号" class="">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="密码" class="">
          <el-input v-model="form.password" type="password"></el-input>
        </el-form-item>
        <el-button type="primary" @click="login" class="btn-login">登录</el-button>
  </el-form>
  </div>
</template>

<script>
const formItemLayout = {
  labelCol: { span: 4 },
  wrapperCol: { span: 20 },
}
const formTailLayout = {
  labelCol: { span: 4 },
  wrapperCol: { span: 20, offset: 4 },
}
export default {
  data () {
    return {
      form: {
        name: '',
        password: ''
      }
    }
  },
  created(){

  },
  mounted () {
    // this.loginName=''
    // this.loginPassword=''
    //
    // let that = this;
    // document.onkeypress = function(e) {
    //   var keycode = document.all ? event.keyCode : e.which;
    //   if (keycode == 13&&that.$route.name=='Login') {
    //     that.login();// 登录方法名
    //     return false;
    //   }
    // };
  },
  methods: {
    check  () {
      this.form.validateFields(
        (err) => {
          if (!err) {
            this.login()
          }
        },
      )
    },
    handleChange  (e) {
      this.checkNick = e.target.checked
      this.$nextTick(() => {
        this.form.validateFields(['nickname'], { force: true })
      })
    },
    onSubmit() {},
     // 获取用户信息
    getCurrentUser(){
      this.$http.post('/user/getCurrentUser', {}).then((res) => {
        if (res.data.code === 200) {

          sessionStorage.setItem('userInfo',JSON.stringify(res.data.content))
          this.$router.push({path: '/content'})
        }
      })
    },
    login() {
      this.$router.push({path: '/content'})
      // this.$http.post('/auth/login', {
      //   "username": this.form.name,
      //   "password": this.form.password
      // }).then(res => {
      //   if(res.data.code===200){
      //     let token=res.data.content.accessToken
      //     sessionStorage.setItem('token',JSON.stringify(token))
      //
      //     sessionStorage.setItem('flag',false)
      //
      //     this.$router.push({path: '/content'})
      //   }
      // }).catch(error => {
      //   // console.log("error");
      // })
    }
  },
}
</script>
<style lang="less" scoped>
  .title{
    text-align:center;
    margin-bottom:30px;
    font-weight:700;
    font-size:26px;
    color:#333;
  }
  .login-form{
    position: absolute;
    width: 400px;
    background-color: rgba(255,255,255,0.8);
    padding: 30px 20px 20px 20px;
    top: 25%;
    right: 150px;
    border-radius: 10px;
  }
  .btn-login{
    margin-left:80px;
    margin-bottom: 5px;
  }
</style>
